import * as path from 'node:path';
import { defineConfig, loadEnv } from '@rsbuild/core';
import { pluginVue } from '@rsbuild/plugin-vue';
const { publicVars } = loadEnv({ prefixes: ['VITE_'] });
const prefix = process.env.VITE_API_URL_PREFIX;
const proxyObj = {
  [prefix]: {
    target: process.env.VITE_BASE_API,
    pathRewrite: { [`^${prefix}`]: '' },
  },
};
console.log(proxyObj);
export default defineConfig({
  server: {
    host: '0.0.0.0',
    port: Number.parseInt(process.env.VITE_PORT, 10),
    proxy: proxyObj,
  },
  resolve: {
    alias: {
      '@': './src',
    },
  },
  html: {
    mountId: 'app',
    template: './public/index.html',
  },
  source: {
    define: publicVars,
  },
  plugins: [pluginVue()],
  performance: {
    removeConsole: true,
  },
});
